package Vista;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Controlador.Sistema;
import Modelo.DubCliente;

import java.awt.BorderLayout;
import java.awt.FlowLayout;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ViewBajaCliente extends javax.swing.JFrame 
{

	private JLabel jLabel4;
	private JButton cancelar;
	private JButton ok;
	private JTextField dni;
	public static ViewBajaCliente instancia;

	private static final long serialVersionUID = 1L;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ViewBajaCliente inst = new ViewBajaCliente();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
				
			}
		});
	}
	
	private ViewBajaCliente() {
		super();
		initGUI();
	}
	
	public static ViewBajaCliente getInstancia() 
	{
		if (instancia== null)
			instancia = new ViewBajaCliente();
		return instancia;
	}
		
	
	public ViewBajaCliente(MenuPrincipal mnu) {
		super();
		initGUI();
		mnu.dispose();
	}
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Baja de Cliente");

			{
				jLabel4 = new JLabel();
				getContentPane().add(jLabel4);
				jLabel4.setText("DNI :");
				jLabel4.setBounds(12, 15, 64, 18);
			}
			{
				dni = new JTextField();
				getContentPane().add(dni);
				dni.setBounds(88, 12, 219, 21);
			}
			{
				ok = new JButton();
				getContentPane().add(ok);
				ok.setText("Aceptar");
				ok.setBounds(95, 45, 105, 21);
				ok.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) 
					{
						boolean a = Sistema.getInstancia().existeCliente(dni.getText());
						if (a == false)
						{
							JOptionPane.showMessageDialog(null, "El Cliente que desea eliminar no existe", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
						}
						else
						{
							Sistema.getInstancia().switchCliente(dni.getText(),0);
							JOptionPane.showMessageDialog(null, "El Cliente fue dado baja exitosamente", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
						}
	
						
					}
				});
			}
			{
				cancelar = new JButton();
				getContentPane().add(cancelar);
				cancelar.setText("Cancelar");
				cancelar.setBounds(205, 45, 114, 21);
			}
			pack();
			this.setSize(339, 105);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
		
}
